class Solution(object):
    def minNumberOperations(self, target):
        last = 0
        ans = 0
        for num in target:
            if num >= last:
                ans += (num - last)
            last = num
        return ans

data = Solution()
target = [1,2,3,2,1]
print(data.minNumberOperations(target))